package tdh.xt.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tdh.xt.dao.BzdmDao;
import tdh.xt.entity.po.Bzdm;
import tdh.xt.service.BzdmService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("bzdmService")
public class BzdmServiceImpl implements BzdmService {

    @Resource(name = "bzdmDao")
    BzdmDao bzdmDao;

    @Transactional(transactionManager = "transactionManager", rollbackFor = {Exception.class})
    @Override
    public List<Bzdm> getXbList() {
        return bzdmDao.getXbList();
    }

    @Transactional(transactionManager = "transactionManager", rollbackFor = {Exception.class})
    @Override
    public Map<String, String> getXbCodeAndName() {
        List<Bzdm> xbList = getXbList();
        Map<String, String> map = new HashMap<String, String>();
        for (Bzdm bzdm : xbList) {
            map.put(bzdm.getCode(), bzdm.getMc());
        }
        return map;
    }
}
